package com.qf.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * User: key
 * ClassName:UserInterceptor
 * Date: 2023/5/26
 * Time: 11:48
 * description:
 */
public class UserInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object loginUser = request.getSession().getAttribute("loginUser");
        if(loginUser != null){
            return true;
        }
        response.sendRedirect("/commons/login.html?msg=Welcome To Emp Manager System");
        return false;
    }
}
